import { http } from "@/utils/http";
import { Result, arrayResult } from "../types";

export type shelvesData = {
  id?: number,
  code?: string,
  name?: string,
  layer?: number,
  column?: number,
  sort?: number,
  warehouseid?: number,
  note?: string
};

type locationsData = {
  rackId?: number,
  code?: string,
  name?: string,
  layerSum?: number,
  columnSum?: number,
  length?: number,
  width?: number,
  height?: number,
  prefix?: string,
  attribute?: number,
  bearingList?: any
};

type shelvesSearch = {
  name: string,
  code: string,
  dateRange: Array<any>,
  begin: string,
  end: string,
  pageNumber: number,
  pageSize: number,
  sortName: string,
  sortType: number
}

// 货架列表
export const shelvesList = (params?: shelvesSearch) => {
  return http.request<Result>("get", "/api/shelves/List", { params });
};

// 新增货架
export const addshelves = (data?: shelvesData) => {
  return http.request<Result>("post", "/api/shelves/Add", { data });
};

// 修改货架
export const updateshelves = (data?: shelvesData) => {
  return http.request<Result>("post", "/api/shelves/Update", { data });
};

// 删除货架
export const delshelves = (id: number) => {
  return http.request<Result>("post", `/api/shelves/Delete/${id}`, {});
};

// 类别列表
export const getCategory = () => {
  return http.request<arrayResult>("get", "/api/Dict/ListByParentCode/Category", {});
};

// 生成货位
export const CreateRackLocations = (data?: locationsData) => {
  return http.request<Result>("post", `/api/shelves/CreateRackLocations`, { data });
};


// 货架select
export const GetAllshelves = () => {
  return http.request<arrayResult>("get", "/api/shelves/GetAllracks", {});
};
